﻿using Domain.Entities;
using Domain.Permissions;
using Domain.Services;
using System.Web.UI;
using UserInterface.Misc;
using UserInterface.UserControls;

namespace UserInterface
{
    public class BoardPageBase : Page
    {
        private Board masterPage;
        private Session currentSession;
        private PermissionManager permissionManager;

        protected void Page_Init()
        {
            masterPage = Master as Board;
            currentSession = SessionManager.CurrentSession;
            permissionManager = new PermissionManager(currentSession.User);
        }

        protected void DieMessage(DieMessageType type, string resourceKey)
        {
            Server.Transfer("~/DieMessage.aspx?type=" + (byte)type + "&resourceKey=" + resourceKey, false);
        }

        protected void DieMessage(DieMessageType type, string resourceKey, string redirectUrl)
        {
            Server.Transfer("~/DieMessage.aspx?type=" + (byte)type + "&resourceKey=" + resourceKey + "&redirectUrl=" + redirectUrl, false);
        }

        protected Board MasterPage
        {
            get { return masterPage; }
        }

        protected Session CurrentSession
        {
            get { return currentSession; }
        }

        protected PermissionManager PermissionManager
        {
            get { return permissionManager; }
        }
    }
}
